#include<iostream>
using namespace std;
#include"MySet.h"
#include"MyMap.h"

void test_set()
{
	cout << "test_set" << endl;
	MoYu::set<int> st;
	int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	//int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto e : a)
	{
		/*if (e == 9)
		{
			int i = 0;
		}*/

		st.insert(e);

		//cout << e << "->" << st.IsBalanceTree() << endl;
		//t.InOrder();
	}
	MoYu::set<int>::iterator be = st.begin();
	MoYu::set<int>::iterator ed = st.end();
	//while (be != ed)
	//{
	//	cout << (*be) << endl;
	//	//cout << 1 << ' ';
	//	++be;
	//}
	while (ed != be)
	{
		--ed;
		cout << *ed << endl;

	}
	MoYu::set<int>::iterator fn1 = st.find(14);
	MoYu::set<int>::iterator fn2 = st.find(23);

	//cout << *fn1 << endl;
	//cout << *fn2 << endl;
}
//#include<map>
void test_map()
{
	cout << "test_map" << endl;
	MoYu::map<int, int> mp;
	//std::map<int, int> mp;
	int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
	//int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
	for (auto e : a)
	{
		/*if (e == 9)
		{
			int i = 0;
		}*/

		mp.insert({e , e + 1});

		//cout << e << "->" << t.IsBalanceTree() << endl;
		//t.InOrder();
	}

	//for (auto e : mp)
	//{
	//	cout << e.first << ' ' << e.second << endl;
	//}
	MoYu::map<int, int>::iterator be = mp.begin();
	MoYu::map<int, int>::iterator ed = mp.end();
	/*std::map<int, int>::iterator be = mp.begin();
	std::map<int, int>::iterator ed = mp.end();*/
	while (be != ed)
	{
		//cout << (*be).first << " ";
		cout << (be->first) << " ";
		++be;
	}
	MoYu::map<int, int>::iterator fn1 = mp.find(14);
	MoYu::map<int, int>::iterator fn2 = mp.find(23);
	cout << endl;
	cout << (*fn1).first << endl;
	//cout << (*fn2).first << endl;
}

int main()
{
	test_set();
	test_map();
}